import json
import threading
from time import sleep



class HeartCheck(threading.Thread):

    def __init__(self,mac_address,mq):
        super().__init__()
        #mac地址
        self.__mac_address = mac_address
        #消息队列对象
        self.__mq = mq

    def run(self):
        #组装数据
        status_data = {
            "macAddress": self.__mac_address,
            "status": 1
        }
        #转成JSON
        status_data = json.dumps(status_data)

        while True:
            #生产消息
            self.__mq.produce_status_info(status_data)
            sleep(3)


